/**
 * This class is similar to the one used as an example in BIEMAN, J. M., AND
 * KANG, B.-K. Cohesion and reuse in an object oriented system. SIGSOFT Softw.
 * Eng. Notes 20, SI (1995), 259-262.  It differs in that it has some private
 * methods, some of which access member data, and some of which do not.
 * 
 * @author Keith Cassell
 */
package nz.ac.vuw.ecs.kcassell.traditional;

public class Stack1 {
	int top, size;
	int[] array;

	public Stack1(int s) {
		size = s;
		array = new int[size];
		top = 0;
	}

	public boolean Isempty() {
		return top == 0;
	}

	public void Push(int item) {
		if (top == size)
			print("Full stack.");
		else
			array[top++] = item;
	}

	public int Pop() {
		if (Isempty())
			print("Empty stack.");
		else
			--top;
		return array[top + 1];
	}

	public void printStack() {
		printLoop();
	}

	private void printLoop() {
		for (int i = 0; i < top; i++) {
			println("" + array[i]);
		}
	}

	private void println(String s) {
		print(s + "\n");
	}

	private void print(String s) {
		System.out.println(s);
	}
}
